package cn.tedu;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;

/**
 * @Classname: Test
 * @Author: bromide
 * @CreateTime: 2022/5/10--18:44
 * @Version: V1.0
 * @Description:
 */
public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入姓名:");
        String name = scanner.nextLine();

        System.out.print("请输入时间:");
        String time = scanner.nextLine();

        System.out.print("请输入关系:");
        String relationship = scanner.nextLine();

        System.out.print("请输入性别:");
        String gender = scanner.nextLine();

        System.out.print("请输入方式:");
        String way = scanner.nextLine();

        System.out.print("请输入金额:");
        int money = scanner.nextInt();

        try(Connection conn = DBUtils.getConn()) {
            PreparedStatement ps = conn.prepareStatement("insert into redpackage values(2,?,?,?,?,?,?)");
            ps.setString(1,name);
            ps.setString(2,time);
            ps.setString(3,relationship);
            ps.setString(4,gender);
            ps.setString(5,way);
            ps.setInt(6,money);
            ps.executeUpdate();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
